import imp, os

class FileEditor:

    config = None

    def __init__(self, filename):
        self.__dict__['config'] = imp.load_source('config_' + os.path.basename(filename), filename)
            
    def __str__(self):
        ret = ''
        for (name, value) in vars(self.__dict__['config']).iteritems():
            if name[0] != '_':
                ret += '%s = %s\n' % (name, repr(value))
        return ret       
             
    def __setattr__(self, name, value):
        setattr(self.__dict__['config'], name, value)
        
    def __getattr__(self, name, value = None):
        return getattr(self.__dict__['config'], name, value)

    def __delattr__(self, name):
        delattr(self.__dict__['config'], name)
